﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;

namespace auxiliary_proj
{
    public partial class FormSettings : Form
    {
        public FormSettings()
        {
            InitializeComponent();

            Program.parseServerInfo();
            tbServer.Text = Program.sServer;
            tbDatabase.Text = Program.sDatabase;
            tbUser.Text = Program.sUser;
            tbPass.Text = Program.sPassword;
        }

        private void btnSettingSave_Click(object sender, EventArgs e)
        {
            //Save the values back to the sever config file
            using (StreamWriter sw = new StreamWriter(Program.PATH + "/Resources/server.ini"))
            {
                try
                {
                    sw.WriteLine("server=" + tbServer.Text);
                    sw.WriteLine("database=" + tbDatabase.Text);
                    sw.WriteLine("user=" + tbUser.Text);
                    sw.WriteLine("pass=" + tbPass.Text);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
                finally
                {
                    Close();
                }
            }
        }
    }
}
